import Vue from 'vue';
import VueRouter from 'vue-router';
import AppIndex from '../components/Home/AppIndex';
import AdminIndex from '../components/admin/AdminIndex'
import UserIndex from '../components/user/UserIndex'

Vue.use(VueRouter);

export default new VueRouter({
  mode:'history',
  routes: [
    {
      path: '/',
      name:'Home',
      component: ()=> import('../components/Home'),
      redirect: '/index',
      children:[
        {
          path: '/index',
          name: 'AppIndex',
          component: AppIndex,
          meta: {
            requireAuth: true
          }
        },
        {
          path:'/question',
          name: 'Question',
          component:()=>import('../components/question/Question'),
          meta: {
            requireAuth: true
          }
        },{
          path:'/question/details',
          name:'QuestionDetails',
          component:()=>import('../components/question/Details'),
          meta:{
            requireAuth: true
          }
        },{
          path:'/blog/details',
          name:'BlogDetails',
          component:()=>import('../components/blog/Details'),
          meta:{
            requireAuth: true
          }
        },
        {
          path: '/admin/content/editorQuestion',
          name: 'EditorQuestion',
          component: () => import('../components/admin/common/editQuestion'),
          meta: {
            requireAuth: true
          },
        },
        {
          path: '/admin/content/editorBlog',
          name: 'EditorBlog',
          component: () => import('../components/admin/common/editBlog'),
          meta: {
            requireAuth: true
          },
        },
        {
          path: '/blog',
          name: 'BlogIndex',
          component:()=>import('../components/blog/BlogIndex'),
          meta: {
            requireAuth: true
          },
        },{
          path: '/resource',
          name: 'ResourceIndex',
          component:()=>import('../components/resource/ResourceIndex'),
          meta: {
            requireAuth: true
          },
        },
        {
          path: '/say',
          name: 'SayIndex',
          component:()=>import('../components/Say/SayIndex'),
          meta: {
            requireAuth: true
          },
        }

      ]
    },
    {
      path: '/login',
      component: ()=> import('../components/Login')
    },
    {
      path: '/register',
      component: ()=> import('../components/Register')
    },
    {
      path: '/test',
      component:()=> import('../components/test')
    },
    {
      path:'/admin',
      name:'Admin',
      component:AdminIndex,
      redirect:'/user/profile',
      children:[{
          path: '/user/profile',
          name:'UserProfile',
          component: ()=>import('../components/admin/user/UserProfile'),
          redirect: '/user/follow',
          children:[{
          path: '/user/resource',
          name:'UserResource',
          component: ()=>import('../components/admin/common/UserResource'),
          meta: {
            requireAuth: true
          }
          },
          {
          path: '/user/follow',
          name:'UserFollow',
          component: ()=>import('../components/admin/userInfo/follow'),
          meta: {
            requireAuth: true
          }
          },
        ]
      },
      {
        path: '/user/list',
        name:'UserInfo',
        component: ()=>import('../components/admin/user/UserInfo'),
        meta: {
          requireAuth: true
        }
      },
      {
        path: '/user/blog',
        name:'BlogManager',
        component: ()=>import('../components/admin/content/BlogManager'),
        meta: {
          requireAuth: true
        }
      },
      {
        path: '/user/question',
        name:'QuestionManager',
        component: ()=>import('../components/admin/content/QuestionManager'),
        meta: {
          requireAuth: true
        }
      },
      {
        path: '/user/comment',
        name:'CommentManager',
        component: ()=>import('../components/admin/content/Comment'),
        meta: {
          requireAuth: true
        }
      },

      ]
    },
    {
      path:'/userIndex',
      name:'userIndex',
      component: UserIndex,
    },
    {
      path: '*',
      component:()=>('../components/error/Error404')
    },
  ]
})


